#include <iostream>
using namespace std;

/**
    【题目224】定义一个Shape抽象类，在此基础上派生出Rectangle和Circle,
        二者都有GetArea()函数计算对象的面积，GetPerim(O函数计算对象的周长。
 */

class Shape
{
public:
    virtual void GetArea() = 0;
    virtual void GetPerim() = 0;
};
class Rectangle : public Shape
{

public:
    Rectangle(int l, int w)
    {
        length = l;
        width = w;
    }
    void GetArea()
    {
        cout << "矩形的面积：" << length * width << endl;
    }
    void GetPerim()
    {
        cout << "矩形的周长: " << 2 * (length + width) << endl;
    }

private:
    int length;
    int width;
};

class Circle : public Shape
{

public:
    Circle(int r)
    {
        radius = r;
    }
    void GetArea()
    {
        cout << "圆的面积: " << 3.14 * radius * radius << endl;
    }
    void GetPerim()
    {
        cout << "圆的周长: " << 2 * 3.14 * radius << endl;
    }
private:
    int radius;
};

int main()
{

    Rectangle r(5, 10);
    Circle c(5);
    r.GetArea();
    r.GetPerim();
    c.GetArea();
    c.GetPerim();
    return 0;
}